package com.wsl;


import com.wsl.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:WangShuliang
 * @Description:
 * @Date:Created in 9:08 2017/12/12
 * @Modified by:
 */
@RestController
public class MailServiceTest {
    @Autowired
    private MailService mailService;

    @RequestMapping("/wsl")
    public String testSimpleMail() throws Exception {
        mailService.sendSimpleMail("1977986356@qq.com", "来自于遥远的北京", "峻俭   我爱你");
        return "发送成功";
    }

    @RequestMapping("/html")
    public String testHtmlMail() throws Exception {
        String content = "<html>\n" +
                "<body>\n" +
                "    <h3>hello world</h3>\n" +
                "</body>\n" +
                "</html>";
        mailService.sendHtmlMail("1977986356@qq.com", "html邮件", content);
        return "html 邮件发送成功";
    }

    @RequestMapping("/attach")
    public String sendAttachmentsmail() {
        String content = "<html>\n" +
                "<body>\n" +
                "    <h3>hello world</h3>\n" +
                "</body>\n" +
                "</html>";

        mailService.sendAttachmentsMail("1977986356@qq.com", "带附件的邮件", content, "E:\\PDM\\wangshuliang.PDM");
        return "带附件的邮件";
    }

    @RequestMapping("/img")
    public void sendInlineResourceMail() {
        String rscId = "neo006";
        String content = "<html><body>这是有图片的邮件:<img src=\'cid:" + rscId + "\'></body></html>";
        String imgPath = "E:\\PDM\\1513059770571.jpg";
        mailService.sendInlineResourceMail("1977986356@qq.com", "主题:这是有图片的文件", content, imgPath, rscId);
    }


}